﻿@using EmployeeLeaveSystem.Shared;
@using EmployeeLeaveSystem.Shared.Models;
@inject IMessageService _MessageService;
@inject HttpClient _HttpClient;

<h5>人事调动查看</h5>

<Descriptions Title="相关细则一览" Bordered Column="@column">
    <DescriptionsItem Title="编号">
        @addMoveDepartment.Id
    </DescriptionsItem>
    <DescriptionsItem Title="申请人编号">
        @addMoveDepartment.StaffId
    </DescriptionsItem>
    <DescriptionsItem Title="申请人姓名">
        @addMoveDepartment.Staff?.Name
    </DescriptionsItem>
    <DescriptionsItem Title="去向部门">
        @addMoveDepartment.ToDepartment?.Name
    </DescriptionsItem>
    <DescriptionsItem Title="申请时间">
        @addMoveDepartment.Created
    </DescriptionsItem>
    <DescriptionsItem Title="去向部门信息">@addMoveDepartment.ToDepartment?.Description</DescriptionsItem>
    <DescriptionsItem Title="理由">@addMoveDepartment.Reason</DescriptionsItem>
</Descriptions>
<div style="height:10px" />
<Paragraph>
    <div class="ant-descriptions-title">附件</div>
</Paragraph>
<Paragraph>
    @foreach (var item in addMoveDepartment.Files) {
        <a href="@("ImgsReq/"+item.FileName)" download="@item.FileName">@item.FileName</a>
    }
    @if (addMoveDepartment.Files.Count == 0) {
        <Empty />
    }
</Paragraph>

@code {
    [Parameter]
    public int Id { get; set; }

    AddMoveDepartment addMoveDepartment = new();
    protected override async void OnInitialized() {
        try {
            addMoveDepartment = await _HttpClient.GetFromJsonAsync<AddMoveDepartment>($"api/Move/GetInfoMoveById?id={Id}");
        }
        catch (Exception ex) {
            _MessageService.Error("获取信息失败");
            App._appHandle.NoticeWithIcon(NotificationType.Error, "失败", ex.Message);
        }
        InvokeAsync(StateHasChanged);
        _MessageService.Success("刷新数据成功");
        base.OnInitialized();
    }
    // 样式布局
    private Dictionary<string, int> column = new Dictionary<string, int> {
            { "xxl", 3 },
            { "xl", 3},
            { "lg", 2},
            { "md", 2},
            { "sm", 1},
            { "xs", 1}
        };
}
